home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / class / lookupky.d < prev    next >
Text File  |  1996-04-28  |  1KB  |  101 lines

  1.  
  2. /*
  3.  *
  4.  *    Copyright (c) 1993-1996 Algorithms Corporation
  5.  *    3020 Liberty Hills Drive
  6.  *    Franklin, TN  37067
  7.  *
  8.  *    ALL RIGHTS RESERVED.
  9.  *
  10.  *
  11.  *
  12.  */
  13.  
  14.  
  15. defclass  LookupKey : Association  {
  16.     iKey;
  17. };
  18.  
  19. cmeth    gNewWithObj, <vNew> (key)
  20. {
  21.     object    luk;
  22.     ivType    *iv;
  23.  
  24.     ChkArgNul(key, 2);
  25.     luk = gNew(super);
  26.     iv = ivPtr(luk);
  27.     iKey = key;
  28.     return luk;
  29. }
  30.  
  31. imeth    gDeepCopy()
  32. {
  33.     object    nobj;
  34.     ivType    *niv;
  35.  
  36.     nobj = gDeepCopy(super);
  37.     niv = ivPtr(nobj);
  38.     if (niv->iKey)
  39.         niv->iKey = gDeepCopy(iKey);
  40.     return nobj;
  41. }
  42.  
  43. imeth    gKey()
  44. {
  45.     return iKey;
  46. }
  47.  
  48. imeth    gChangeKey(key)
  49. {
  50.     object    old;
  51.     ChkArgNul(key, 2);
  52.     old = iKey;
  53.     iKey = key;
  54.     return old;
  55. }
  56.  
  57. imeth    object    gDeepDispose()
  58. {
  59.     if (iKey)
  60.         gDeepDispose(iKey);
  61.     return gDispose(super);
  62. }
  63.  
  64. imeth    gStringRepValue()
  65. {
  66.     return iKey ? gStringRepValue(iKey) : gNew(String);
  67. }
  68.  
  69. imeth    int    gHash()
  70. {
  71.     return iKey ? gHash(iKey) : 0;
  72. }
  73.  
  74. imeth    int    gCompare(arg)
  75. {
  76.     ChkArgNul(arg, 2);
  77.     if (!iKey  &&  !arg)
  78.         return 0;
  79.     if (!iKey)
  80.         return -1;
  81.     if (!arg)
  82.         return 1;
  83.     return gCompare(iKey, gKey(arg));
  84. }
  85.  
  86.  
  87.  
  88.  
  89. /*
  90.  *
  91.  *    Copyright (c) 1993-1996 Algorithms Corporation
  92.  *    3020 Liberty Hills Drive
  93.  *    Franklin, TN  37067
  94.  *
  95.  *    ALL RIGHTS RESERVED.
  96.  *
  97.  *
  98.  *
  99.  */
  100.  
  101.